Implement CloseContext remapper for PlayerQuitEvent handling#260
Merged
twisti-dev merged 2 commits intoversion/1.21.11from Mar 21, 2026
Merged
Implement CloseContext remapper for PlayerQuitEvent handling#260twisti-dev merged 2 commits intoversion/1.21.11from
twisti-dev merged 2 commits intoversion/1.21.11from
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new runtime bytecode remapping solution to address a compatibility issue with the inventory-framework library, specifically around the handling of close events in inventory views. The main change is the addition of the
CloseContextRemapper, which rewrites the bytecode of third-party classes so that theCloseContextclass and related factory methods can accept any event object (not justInventoryCloseEvent), preventing runtimeClassCastExceptions when handling player quit events.The most important changes are:
Bytecode Remapping for Inventory Framework Compatibility:
CloseContextRemapperinCloseContextRemapper.kt, which uses ByteBuddy and ASM to rewrite theCloseContextandBukkitElementFactoryclasses at runtime so that thecloseOriginparameter and field are typed asObjectinstead ofInventoryCloseEvent. This removes unsafe casts and makes the code compatible with bothInventoryCloseEventandPlayerQuitEvent.InventoryLoader.ktto invokeCloseContextRemapper.remap()during initialization, ensuring the remapping is applied as soon as the inventory framework is loaded.Versioning:
gradle.propertiesfrom1.21.11-2.70.1to1.21.11-2.70.2to reflect these changes.